package zuoye.zuoye1;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateUtils {
    //把日期转换为指定格式的字符串
    public static void formatDate(LocalDateTime time, String format) {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern(format);
        String format1 = dtf.format(time);
        System.out.println(format1);

    }
        //把字符串解析为指定格式的日期
    public static LocalDateTime parseDate( String format1) {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return LocalDateTime.parse(format1, dtf);
    }
}
